<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的</title>
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/homePage.css">
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/flexible.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/MD5.js"></script>
    <script src="js/vant.js"></script>
</head>
<body>
<div class="container_box" id="app">
    <header>
        <div class="search bar3">
            <div>
                <form @submit.prevent action="#">
                    <input @keyup.enter.native="search" v-model="from.username" type="search" placeholder="搜索会员姓名/手机号码">
                    <button @click="search" type="text"><img src="images/search.png"></button>
                </form>
            </div>
        </div>
    </header>

    <div class="add_jl" @click="addMP"><img src="images/add_jl.png"></div>
    <template>
        <div @click="details(item.id)" class="group_details group_details_state clearfix" v-for="item in list" :key="item.id">
            <div class="fl head_card">
                <img :src="item.Picurl" alt="" class="spinning_img">
            </div>
            <div class="spinning_txt fl">
                <p class="margin_bottom">
                    <span class="font_size12">{{item.Username}}</span>
                    <span class="spinning_txx">{{item.donggandanche}}</span>
                    <span class="rf">
                        <span class="font_size12">客户来源:</span>
                        <span class="font_size12">{{item.Fromname}}</span>
                    </span>
                </p>
                <p style="margin-bottom: 0.1rem;">
                    <span class="spinning_name">{{item.Phone}}</span>
                    <span class="font_size12 rf">
                        <span class="font_size12">跟进</span>
                        <span class="font_size12">{{item.Follow}}</span>
                    </span>
                </p>
            </div>
        </div>
    </template>
    <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
    >
    <van-cell
        v-for="item in lists"
        :key="item"
        :title="item"
    />
    </van-list>
    <div class="add_jls"><a href="index.html"><img src="images/back.png"></a></div>
</div>
</body>
<script>
new Vue({
    el: '#app',
    data: {
        lists: [],
        loading: false,
        finished: false,
        logoShow:false,
        list:[],
        from:{
            type:'',
            state:'',
            username:'',
            page:'1'
        },
        moren:'images/moren.png',
        page:'',
        totalnum:'',
        totalpage:'',
        listd:[]
    },
    created(){
        this.setCanS()
    },
    methods:{
         //设置参数
         setCanS(){
            let Request = new Object()
            Request = GetRequest()
            this.from.type = Request['type']
            this.from.state = parseInt(Request['state'])
            if(this.from.type=='1'){
                this.from.type=''
            }
        },
        onLoad() {
            setTimeout(() => {
                 // 异步更新数据
                const params={
                    type:this.from.type,
                    state:this.from.state,
                    username:this.from.username,
                    page:this.from.page
                }
                getVs()
                axios.get('/mobileapi/adviser/index.php?act=alluser',{params:params}).then(data =>{
                    console.log(data.data)
                    let { msg, code,user} = data.data
                        if (code !== 200) {
                            window.vant.Toast.fail(msg)
                        } else {
                            data=data.data
                            this.listd=data.data.list
                            this.totalnum=data.data.totalnum
                            this.from.page=parseInt(data.data.page)+1
                            for(let i in this.listd){
                                if(this.listd[i].Picurl==""||this.listd[i].Picurl==null){
                                    this.listd[i].Picurl='images/moren.png'
                                }
                            }
                            for (let i = 0; i < this.listd.length; i++) {
                                this.list.push(this.listd[i])
                            }
                            // 加载状态结束
                            this.loading = false
                            // 数据全部加载完成
                            if (this.list.length == this.totalnum) {
                                this.finished = true
                                console.log(this.list)
                            }
                        }
                    }).catch(function (error) {
                        console.log(error); 
                })
                console.log(this.listd)
                
            }, 500);
        },
        //获取信息
        getList(){
            const params={
                type:this.from.type,
                state:this.from.state,
                username:this.from.username
            }
            getVs()
            axios.get('/mobileapi/adviser/index.php?act=alluser',{params:params}).then(data =>{
                console.log(data)
                let { msg, code,user} = data.data
                    if (code !== 200) {
                        window.vant.Toast.fail(msg)
                    } else {
                        data=data.data
                        this.list=data.data.list
                        for(let i in this.list){
                            if(this.list[i].Picurl==""||this.list[i].Picurl==null){
                                //alert("2")
                                this.list[i].Picurl='images/moren.png'
                            }
                        }
                    }
                }).catch(function (error) { 
                    console.log(error); 
            });
        },
        //详情
        details(id){
            if(this.from.state=='1'){
                window.location.href='memberDetails.html?uid='+id+''
            }else{
                window.location.href='customerDetails.html?uid='+id+''
            }
        },
        //添加会员或客户
        addMP(){
            if(this.from.state=='1'){
                window.location.href="addMember.html"
            }else{
                window.location.href="customer.html"
            }
        },
        search(){
            this.from.page='1'
            this.list=[]
            this.listd=[]
            this.onLoad()
        }
    }
})
</script>
</html>